{
 "metadata": {
  "kernelspec": {
   "codemirror_mode": {
    "name": "python",
    "version": 3
   },
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "name": "",
  "signature": "sha256:905536d623649541dd8ae044dbe4528581497ae1697e147f46fa1baada1439ee"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import ast\n",
      "from veloce import Veloce"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 4
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%%writefile myscript0.py\n",
      "def g(y):\n",
      "    return y-1"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Overwriting myscript0.py\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "code = \"\"\"\n",
      "from myscript0 import g\n",
      "def f(x):\n",
      "    return g(exp(x)*x)+1\n",
      "print(f(3))\n",
      "\"\"\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 8
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "v = Veloce()\n",
      "v.visit(ast.parse(code))\n",
      "js = v.writer.value()\n",
      "print(js)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "var g = function(y) {\n",
        "    return (y - 1);\n",
        "};\n",
        "var f = function(x) {\n",
        "    return (g((Math.exp(x) * x)) + 1);\n",
        "};\n",
        "console.log(f(3));\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 9
    }
   ],
   "metadata": {}
  }
 ]
}